import * as SysApi from '../sys.api';

export interface ISignInParams {
    username: string;
    password: string
}

export const register = () => {
    SysApi.register('security.signIn', (params: ISignInParams) => {
        if (!params.username || !params.password) {
            return Promise.reject();
        }
        return SysApi.ajaxPost(SysApi.apiUrl('/sign-in'), null, params);
    });

    SysApi.register('security.signOut', () => {
        return SysApi.ajaxGet(SysApi.apiUrl('/sign-out'), { _t: new Date().getTime() });
    });
};